home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / HAMRADIO / KS_CW.ZIP / CW.MS < prev   
Text File  |  1988-10-22  |  11KB  |  269 lines

  1. .pl 63
  2. .LP
  3. .TL
  4. A Morse Code Sending and Receiving Program for the IBM-PC\(tm
  5. .AU
  6. Kevin Schmidt, W9CF
  7. .AB
  8. This is the documentation for CW.C, a program to send
  9. and receive international morse code via the
  10. IBM-PC\(tm serial port.
  11. .AE
  12. .sp 10
  13. .nf
  14. Copyright 1988 by Kevin Schmidt. This document may be reproduced
  15. for any noncommercial purpose as long as credit is given to the author.
  16. .bp
  17. .NH
  18. Introduction
  19. .PP
  20. This documentation is for CW.C a morse code sending
  21. and receiving program written in TURBO-C\(tm 1.0 (with bug patches) for the
  22. IBM-PC\(tm. You should receive the C source with any distribution
  23. of this documentation.
  24. .PP
  25. DISCLAIMER: CW.C bypasses both the BIOS and DOS to reprogram the serial
  26. port hardware and the timer/sound chip. The author takes no responsibility
  27. for what running this code may do to your system. It is provided AS IS
  28. with NO WARRANTEE whatsoever. Run it at your own risk.
  29. .PP
  30. The distribution should contain the files:
  31. .RS
  32. .IP 1.
  33. CW.DOC -- this file
  34. .IP 2.
  35. CW.C -- the source program
  36. .IP 3.
  37. CW.INI -- an example initialization file
  38. .IP 4.
  39. CW.EXE -- (optional) a compiled version of the code. If not supplied or
  40. you want to know what you are using, compile cw.c using TURBO-C\(tm.
  41. My command line to do this is:
  42. .nf
  43. tcc -Lc:\turboc\lib -Ic:\turboc\include cw.c
  44. .fi
  45. where you need to change -L and -I options to correspond to the location
  46. of your library and include files.
  47. .RE
  48. .NH
  49. Setup and Operation
  50. .PP
  51. CW functions as two separate programs one for sending morse from
  52. the keyboard and the other for receiving morse and displaying it on
  53. the screen. The two programs are very loosely coupled. Morse is sent
  54. by toggling the request to send line of the RS-232 serial port.
  55. Mark is +12V and space is -12V. Similarly morse characters are 
  56. received by looking at the clear to send line of the RS-232 port.
  57. .PP
  58. To get started, put CW.EXE in a subdirectory and put CW.INI in the
  59. same subdirectory. Edit the file CW.INI and put in any commands
  60. that you want executed at startup in this file. The example file
  61. is:
  62. .nf
  63. sound off
  64. sound 40
  65. serial 3f8 4
  66. b1  cq cq cq de w9cf w9cf w9cf k 
  67. b2  r tnx for call = rst 
  68. b3  = qth new york city ny = name kevin = hw? 
  69. b4  de w9cf k 
  70. .fi
  71. These commands first turn off the speaker which normally beeps
  72. whenever an input mark is detected. The frequency of the beep
  73. is set to 40HZ. This will be the frequency of the beep if the
  74. sound is turned back on. Next the serial port is set to com1.
  75. Com1 is the default so this line is unnecessary. For com2 you
  76. would use the command serial 2f8 3. See the serial command below
  77. for more information. There are ten send buffers. The first
  78. 4 are set in the next 4 lines. Each of these ends with a
  79. space so that a space is the last character sent. However, this
  80. space does not show above. Modify the buffers to hold whatever
  81. you like.
  82. .PP
  83. To test the code, you can loop back the sender to the receiver.
  84. Do this by shorting the clear to send line of the RS-232
  85. port to the request to send line. These should be pins 4 and 5
  86. of a 25 pin connector. Start up CW. The top of the screen holds
  87. help information. The middle of the screen is the receive display
  88. and the bottom portion is the transmit display. The last line
  89. is used as a command line and will be described later.
  90. .PP
  91. Type something at the keyboard. It should be displayed in the
  92. transmit region. Now hit the f9 function key. This will tell the
  93. computer to send the text in the transmit queue out the serial port.
  94. Since this is looped back to the receiver, it should be displayed
  95. in the middle portion of the screen. If you want to hear the
  96. code on the speaker hit the f1 key. Alternatively, you can leave the sound off
  97. line out of cw.ini or replace it with sound on. Note, the speaker is connected
  98. to the receive section. Transmitted characters will not sound the speaker
  99. unless it is looped back to the receiver.
  100. .NH
  101. Help Screen and function keys
  102. .PP
  103. The help screen displays the following information:
  104. .RS
  105. .IP 1.
  106. auto or man -- indicating whether the receive speed is set by the program
  107. by analyzing the incoming morse, or by the operator. Manual mode is probably
  108. necessary if you want to hook this up to a radio.
  109. .IP 2.
  110. dot -- this displays the current speed in words per minute of what the code
  111. thinks are incoming dots.
  112. .IP 3.
  113. dash -- this displays the current speed in words per minute of what the code
  114. thinks are incoming dashs.
  115. .IP 4.
  116. el sp -- this displays the current speed in words per minute of the spaces
  117. between dots and dashes.
  118. .IP 5.
  119. lt sp -- this displays the current speed in words per minute of the spaces
  120. between letters.
  121. .IP 6.
  122. rcv -- this displays the approximate receive speed in words per minute if the
  123. program is set to auto. In manual mode, it displays the manually set
  124. receive speed.
  125. .IP 7.
  126. The other items are a quick reference to what the function keys do, and
  127. how to get command line help.
  128. .RE
  129. .PP
  130. The 10 function keys are set up as follows:
  131. .RS
  132. .IP f1.
  133. -- toggles the speaker on and off.
  134. .IP f2.
  135. -- toggles the receive speed from automatic to manual.
  136. .IP f3.
  137. -- in manual mode decreases the receive speed.
  138. .IP f4.
  139. -- in manual mode increases the receive speed.
  140. .IP f5.
  141. -- increases the transmit speed.
  142. .IP f6.
  143. -- decreases the transmit speed.
  144. .IP f7.
  145. -- set transmit speed to current receive speed.
  146. .IP f8.
  147. -- enter a command in command mode.
  148. .IP f9.
  149. -- toggle from send mode to hold mode. In hold mode, text is entered
  150. in the transmit queue but is not sent until send mode is toggled.
  151. .IP f10.
  152. -- exit from CW program.
  153. .IP Shift-f?.
  154. -- i.e. hold down the shift and function key,
  155. where ? is 1 through 10 causes the corresponding numbered buffer to be
  156. appended to the transmit queue.
  157. .IP CTRL-f?.
  158. -- i.e. hold down the control key and the function key. This erases the
  159. contents of the corresponding numbered buffer and prompts for new text.
  160. It is usually a good idea to end text with a space. A carriage return
  161. (enter key) terminates the text.
  162. .IP ALT-f?.
  163. -- i.e. hold down the alt key and the function key. This displays the
  164. current text in the corresponding numbered buffer.
  165. .RE
  166. .NH
  167. Commands
  168. .PP
  169. The following commands are allowed in command mode. Any command listed
  170. here may also be used in the startup file.
  171. .RS
  172. .IP
  173. read filename -- reads in the filename specified and sends it.
  174. .IP
  175. sound on -- turns on the speaker.
  176. .IP
  177. sound off -- turns off the speaker.
  178. .IP
  179. sound nnnn -- where nnnn is a number, sets the sound frequency to nnnn.
  180. .IP
  181. receive automatic -- set receive speed to automatic.
  182. .IP
  183. receive manual -- set receive speed to manual.
  184. .IP
  185. receive nn -- where nn is a number, sets receive speed to nn words per minute.
  186. .IP
  187. serial hhhh h -- sets the serial port. hhhh is the serial port base address
  188. in hex and h is the hardware interrupt vector used by the serial port.
  189. Initially, this is set to 3f8 4 which is normal for com1. Com2 uses
  190. 2f8 3. For other serial ports you will have to fill in the correct values.
  191. You should also check the interrupt handler in the source code to make
  192. sure it does what you want.
  193. .IP
  194. stretch nnnn -- where nnnn is a number, reduces marks and increases spaces
  195. by nnnn*840 nanoseconds. This can be helpful to compensate for pulse
  196. stretching in audio filters.
  197. .IP
  198. bn text -- where n is a number from 1 to 10, fills corresponding buffer
  199. with text where text is whatever is to be sent.
  200. .IP
  201. transmit on -- tells program to send text in transmit queue (see f9 above).
  202. .IP
  203. transmit off -- tells program to hold text in transmit queue (see f9 above).
  204. .RE
  205. .NH
  206. Theory of Operation
  207. .PP
  208. Only a very brief theory of operation will be given.
  209. .PP
  210. The program can be divided into three parts. The first part is an interrupt
  211. handler for the serial port. The serial port is set to interrupt on
  212. change of the modem status. In particular, this happens when the clear
  213. to send line is changed. The interrupt handler simply records the
  214. status of the clear to send line in queue.mark and the time since
  215. the clear to send line last changed in queue.mstime and increments
  216. the queue pointer countin. The serial port stuff is fairly standard
  217. and I used the description given by of R. Jourdain,
  218. "Programmer's Problem Solver for the IBM PC,XT, and AT",
  219. (Prentice Hall, 1986, NY) although he gets the interrupt numbers wrong.
  220. The method used for timing the marks 
  221. and spaces is adapted from B. Sheppard, "High Performance Software
  222. Analysis on the IBM PC", BYTE, January 1987.
  223. .PP
  224. The second part of the code is a replacement for the IRQ0 timer
  225. interrupt. I change the timer to interrupt SPEEDUP times faster
  226. than original. Every SPEEDUP interrupts the old interrupt handler is
  227. called so that disk operations and the bios date should be unaffected.
  228. The replacement interrupt handler takes characters from a queue
  229. and keys the request to send line of the serial port. Note if
  230. you only want to receive morse this replacement routine is not
  231. necessary since microsecond receive timing accuracy can be obtained without
  232. changing this interrupt. Just change SPEEDUP to 1. Note SPEEDUP
  233. must be a power of 2.
  234. .PP
  235. The last part of the code is the human interface, which looks at
  236. the receive queue and displays the result along with some statistics,
  237. and also fills the transmit queue.
  238. .PP
  239. The code has been tested on my 6MHZ ibm pc-at running dos 3.1
  240. with CGA and serial/parallel adaptor and on a zenith z-181 portable.
  241. Any other 80 column or greater display should work. Since the clock
  242. chip is reprogrammed and serial port interrupts are used,
  243. probably only hardware as well as bios level clones of the IBM PC will
  244. run this code. If you are attempting to run this code on a particularly
  245. slow PC, you may want to set SPEEDUP to 1 to start. After everything
  246. is working correctly, increase speedup to get the desired set of
  247. transmit speeds. The possible transmit speeds are given by
  248. dot length = N*840ns*65536/(SPEEDUP) where N is an integer, ns
  249. stands for nanoseconds, and SPEEDUP must be a power of 2 for proper
  250. operation.
  251. .PP
  252. Most of the information in this section is contained in the source code
  253. comments, which also give some additional information.
  254. .NH
  255. Conclusion
  256. .PP
  257. I originally wrote this code as a tool to help teach morse. By hooking
  258. a code key to toggle the clear to send line, the student can see what
  259. she is sending and get a fair idea if her spacing is correct. The
  260. sending portion was added when I needed a cw keyboard for my transmitter.
  261. .PP
  262. I have connected the PC  to my receiver. It is fairly easy to receive
  263. strong signals using machine produced
  264. code like that from W1AW, but much more difficult to deal with noisy
  265. signals and hand sending.
  266. .PP
  267. I do not plan to work on this code in the future. However, if you
  268. have questions, I can be contacted at my address listed in the call book.
  269.